package operate;

import book.Book;
import book.BookList;

import java.util.Scanner;

public class ReturnBook implements MyInterface {
    @Override
    public void work(BookList bookList) {
        System.out.println("归还图书");
        System.out.println("请输入所要归还的书名：");
        Scanner sc = new Scanner(System.in);
        String name = sc.nextLine();

        int countSize = bookList.getUsedSize();
        for (int i = 0; i < countSize; i++) {
            Book book2 = bookList.getBook(i);
            if (book2.getName().equals(name)) {
                    book2.setFlg(false);
                    System.out.println("归还成功");
                return;
            }
        }
        System.out.println("没有这本书");
    }
}

